<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="ctm.javacode.classificationfood"%>
<%@page import ="java.util.*" %>
<%@page import ="java.text.DecimalFormat"%>
<%@ page import="java.sql.*" %>
<jsp:useBean id="db" class="ctm.javacode.dbBean"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>飲食建議列印</title>
<script language="Javascript" type="text/javascript" src="./JQuery/Calculation.js"></script>
<style type="text/css">
body,td,th {
	color: #000000;
	font-size:20px;
	font-family:"標楷體";
}
.HEAD_STYLE {
	font-weight:bold;
	color: #437A27;
	font-family:"標楷體";
	font-size:30px; 
}
span{
	color: #000000;
	font-size:24px;
	font-family:"標楷體";
	font-weight:bold;	
}
.button
{
	border:1px;
	padding-top: 4px;
	padding-right: 7px;
	padding-bottom: 4px;
	padding-left: 7px;
	background-color: #468129;
	color: #FFFFFF;
	font-size: 16px;
	border-color: #3C7023;
}
.food {
	background-image: url(img/food.jpg);
	background-color: #FFFFFF;
	background-repeat: no-repeat; 
}

.class2 a:link {
	text-decoration: none;
	font-family: "標楷體";
	font-size: 20px;
	color: #000000;
}

.class2 a:visited {
	text-decoration: none;
	font-family: "標楷體";
	font-size: 20px;
	color: #000000;
}
.class2 a:active {
	text-decoration: none;
	font-family: "標楷體";
	font-size: 20px;
	color: #0000FF;
}
.class2 a:hover {
	text-decoration: none;
	font-family: "標楷體";
	font-size: 20px;
	color: #0000FF;
}
.ind:link {
	color: #535353;
	text-decoration:none;
	font-family:"標楷體";
	font-size:18px;
}
.ind:visited {
	color:#535353;
	text-decoration:none;
	font-family:"標楷體";
	font-size:18px;
}
.ind:hover {
	color:#BB280F;
	text-decoration:none;
	font-family:"標楷體";
	font-size:18px;
}
.TEXT_STYLE {
	font-family:"標楷體";  
	color:#437A27;
	font-size:24px;
}
.TEXT_STYLE_2 {
	font-family:"標楷體";  
	color:#000000;
	font-size:24px;
}
.BOTTOM_STYLE {
	color: #FFFFFF; 
	font-family: Arial; 
	font-size:20px;
}
.LEFT_BUTTON {
	font-family:"標楷體"; 
	font-size:30px;
}
.style {
	font-size: 20px; 
	color: #000000; 
	font-weight: bold;
}
.off {
	display: none;
}
</style>
</head>
<body>
<%
double calofday = Double.parseDouble(request.getAttribute("calofday").toString()) ;

double cho = Double.parseDouble(request.getAttribute("cho").toString()) ;
double fat = Double.parseDouble(request.getAttribute("fat").toString()) ;
double prot = Double.parseDouble(request.getAttribute("prot").toString()) ;

double proportion_prot = Double.parseDouble(request.getAttribute("proportion_prot").toString());
double proportion_fat = Double.parseDouble(request.getAttribute("proportion_fat").toString());
double proportion_cho = Double.parseDouble(request.getAttribute("proportion_cho").toString());

double quantity_Milk = Double.parseDouble(request.getAttribute("quantity_Milk").toString());
double quantity_Veg = Double.parseDouble(request.getAttribute("quantity_Veg").toString()); 
double quantity_Fruit = Double.parseDouble(request.getAttribute("quantity_Fruit").toString());
double quantity_Grain = Double.parseDouble(request.getAttribute("quantity_Grain").toString());
double quantity_Meat = Double.parseDouble(request.getAttribute("quantity_Meat").toString());
double quantity_Fat = Double.parseDouble(request.getAttribute("quantity_Fat").toString());

double img_Grain = Double.parseDouble(request.getAttribute("img_Grain").toString());
double img_Fat = Double.parseDouble(request.getAttribute("img_Fat").toString());

double breakfast_Milk = Double.parseDouble(request.getAttribute("breakfast_Milk").toString()) ;	
double lunch_Milk = Double.parseDouble(request.getAttribute("lunch_Milk").toString()) ;	
double dinner_Milk = Double.parseDouble(request.getAttribute("dinner_Milk").toString()) ;	

double breakfast_Veg = Double.parseDouble(request.getAttribute("breakfast_Veg").toString()) ;	
double lunch_Veg = Double.parseDouble(request.getAttribute("lunch_Veg").toString()) ;	
double dinner_Veg = Double.parseDouble(request.getAttribute("dinner_Veg").toString()) ;

double breakfast_Fruit = Double.parseDouble(request.getAttribute("breakfast_Fruit").toString()) ;	
double lunch_Fruit = Double.parseDouble(request.getAttribute("lunch_Fruit").toString()) ;	
double dinner_Fruit = Double.parseDouble(request.getAttribute("dinner_Fruit").toString()) ;	

double breakfast_Grain = Double.parseDouble(request.getAttribute("breakfast_Grain").toString()) ;	
double lunch_Grain = Double.parseDouble(request.getAttribute("lunch_Grain").toString()) ;	
double dinner_Grain = Double.parseDouble(request.getAttribute("dinner_Grain").toString()) ;	

double breakfast_Meat = Double.parseDouble(request.getAttribute("breakfast_Meat").toString()) ;	
double lunch_Meat = Double.parseDouble(request.getAttribute("lunch_Meat").toString()) ;	
double dinner_Meat = Double.parseDouble(request.getAttribute("dinner_Meat").toString()) ;	

double breakfast_Fat = Double.parseDouble(request.getAttribute("breakfast_Fat").toString()) ;	
double lunch_Fat = Double.parseDouble(request.getAttribute("lunch_Fat").toString()) ;	
double dinner_Fat = Double.parseDouble(request.getAttribute("dinner_Fat").toString()) ;
	
    DecimalFormat df = new DecimalFormat("0"); 
    DecimalFormat df2 = new DecimalFormat("#.#");
    
    /****可用食物列表****/
    ArrayList<ArrayList<String>> whole_grain_Suit = new ArrayList<ArrayList<String>>(); // 全穀根莖類
	ArrayList<ArrayList<String>> meat_Suit = new ArrayList<ArrayList<String>>(); // 豆魚肉蛋類
	ArrayList<ArrayList<String>> fat_Suit = new ArrayList<ArrayList<String>>(); // 油脂及堅果種子類
	ArrayList<ArrayList<String>> milk_Suit = new ArrayList<ArrayList<String>>(); // 低脂奶類
	ArrayList<ArrayList<String>> fruit_Suit = new ArrayList<ArrayList<String>>(); // 水果類
	ArrayList<ArrayList<String>> vegetables_Suit = new ArrayList<ArrayList<String>>(); // 蔬菜類
	ArrayList<ArrayList<String>> other_Suit = new ArrayList<ArrayList<String>>(); // 其他類
	/****禁忌食物列表****/
	ArrayList<ArrayList<String>> whole_grain_NotSuit = new ArrayList<ArrayList<String>>(); // 全穀根莖類
	ArrayList<ArrayList<String>> meat_NotSuit = new ArrayList<ArrayList<String>>(); // 豆魚肉蛋類
	ArrayList<ArrayList<String>> fat_NotSuit = new ArrayList<ArrayList<String>>(); // 油脂及堅果種子類
	ArrayList<ArrayList<String>> milk_NotSuit = new ArrayList<ArrayList<String>>(); // 低脂奶類
	ArrayList<ArrayList<String>> fruit_NotSuit = new ArrayList<ArrayList<String>>(); // 水果類
	ArrayList<ArrayList<String>> vegetables_NotSuit = new ArrayList<ArrayList<String>>(); // 蔬菜類
	ArrayList<ArrayList<String>> other_NotSuit = new ArrayList<ArrayList<String>>(); // 其他類
	
	String ac  = (String) session.getAttribute("login");;

	classificationfood _classificationfood = new classificationfood(ac);
	/****可用食物取得****/
	whole_grain_Suit = _classificationfood.getsuitfood("全穀根莖類");
	meat_Suit = _classificationfood.getsuitfood("豆魚肉蛋類");
	fat_Suit = _classificationfood.getsuitfood("油脂及堅果種子類");
	milk_Suit = _classificationfood.getsuitfood("低脂奶類");
	fruit_Suit = _classificationfood.getsuitfood("水果類");
	vegetables_Suit = _classificationfood.getsuitfood("蔬菜類");
	other_Suit = _classificationfood.getsuitfood("其他類");
	/****禁忌食物取得****/
	whole_grain_NotSuit = _classificationfood.getnotsuitfood("全穀根莖類");
	meat_NotSuit = _classificationfood.getnotsuitfood("豆魚肉蛋類");
	fat_NotSuit = _classificationfood.getnotsuitfood("油脂及堅果種子類");
	milk_NotSuit = _classificationfood.getnotsuitfood("低脂奶類");
	fruit_NotSuit = _classificationfood.getnotsuitfood("水果類");
	vegetables_NotSuit = _classificationfood.getnotsuitfood("蔬菜類");
	other_NotSuit = _classificationfood.getnotsuitfood("其他類");

%>

	<div width="80%" align="center">
		<div><a href="javascript:printpage()">列印本頁</a></div>
		<br>
		<span align="center" class="HEAD_STYLE">每日建議熱量</span>
		<table width="50%" align="center" border="1">
			<tr>
				<input type="hidden" id="work"></input>
				<td align="center"><span>三大營養素</span></td>
				<td align="center"><span>建議熱量</span></td>			
			</tr>
			<tr>
				<td align="center"><span>蛋白質</span></td>
				<td align="center">
					<span id="wight" style=display:none><%=df.format(prot)%></span>
					<span id="prot"><%=df.format(prot)%></span><span>克(</span>
					<span id="proportion_prot"><%=df2.format(proportion_prot)%></span><span>%)</span>
				</td>												
			</tr>
			<tr>
				<td align="center"><span>脂肪</span></td>
				<td align="center">
					<span id="fat"><%=df.format(fat)%></span><span>克(30%)</span>
			 	</td>
			</tr>
			<tr>
				<td align="center"><span>醣類</span></td>
				<td align="center">
					<span id="cho"><%=df.format(cho)%></span><span>克(</span>
					<span id="proportion_cho"><%=df2.format(proportion_cho)%></span><span>%)</span>
				</td>									
			</tr>			
			<tr>
				<td align="center"><span>總共</span></td>
				<td align="center">
					<span id="calofday"><%=df.format(calofday)%></span><span>大卡</span>
				</td>			
			</tr>	
		
		</table>
		<br>
		<table width="50%" align="center" border="1">
			<tr>
				<td align="center"><span>六大類食物</span></td>
				<td align="center"><span>建議份量(±0.5份)</span></td>
			</tr>
			<tr>
				<td align="center"><span>低脂奶類</span></td>
				<td align="center"><span><%=df2.format(quantity_Milk)%></span>
				</td>
			</tr>
			<tr>
				<td align="center"><span>蔬菜類</span></td>
				<td align="center"><span><%=df2.format(quantity_Veg)%></span></td>
			</tr>
			<tr>
				<td align="center"><span>水果類</span></td>
				<td align="center"><span><%=df2.format(quantity_Fruit)%></span>
				</td>
			</tr>
			<tr>
				<td align="center"><span>全穀根莖類</span></td>
				<td align="center"><span id="quantity_Grain"><%=df2.format(quantity_Grain)%></span>
				</td>
			</tr>
			<tr>
				<td align="center"><span>豆魚肉蛋類</span></td>
				<td align="center"><span id="quantity_Meat"><%=df2.format(quantity_Meat)%></span>
				</td>
			</tr>
			<tr>
				<td align="center"><span>油脂及堅果種子類</span></td>
				<td align="center"><span id="quantity_Fat"><%=df2.format(quantity_Fat)%></span>
				</td>
			</tr>
		</table>
		<br>
		<table height="400" width="918" align="center" class="food"
			cellpadding="0" border="0"> 
			<tr>
				<td width="25%" height="147" class="style"></td>
				<td width="10%" class="style"></td>
				<td width="25%" class="style"></td>
				<td width="40%" class="style"></td>
			</tr>
			<tr>
				<td class="style"></td>
				<td class="style"></td>
				<td class="style">&nbsp;&nbsp;</td>
				<td class="style"></td>
			</tr>
			<tr>
				<td class="style"></td>
				<td class="style"></td>
				<td class="style">
					<div class="style" align="center">全榖根莖類<br> </div> 
				</td>
				<td class="style">&nbsp;&nbsp;&nbsp;</td>
			</tr>
			<tr>
				<td class="style"></td>
				<td class="style">
					 
				</td>
				<td class="style" align="center">				
					<span class="style"><%=df2.format(img_Grain)%>碗</span>
				</td>
				<td class="style">
					<div class="class2" align="left">豆魚肉蛋類</div> 
				</td>
			</tr>
			<tr>
				<td class="style"></td>
				<td class="style">
					<div class="style" align="right">蔬菜類</div>
				</td>
				<td class="style"></td>
				<td class="style" align="left">
					&nbsp;&nbsp; <%=df2.format(quantity_Meat)%>份				
				</td>
			</tr>
			<tr>
				<td></td>
				<td class="style"  align="right">
					<span class="style"><%=df2.format(quantity_Veg)%>份 &nbsp;</span>
				</td>
				<td></td>
				<td class="style">
					<div class="class2" align="center">
							低脂奶類
					</div> 
				</td>
			</tr>
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td class="style" align="center">
					<%=df.format(quantity_Milk * 240)%>毫升
				</td>
			</tr>
			<tr>
				<td></td>
				<td class="style">
					<div class="class2" align="center"> 水果類 </div> 
				</td>
				<td></td>
				<td></td>
			</tr>
			<tr>
				<td class="style"></td>
				<td class="style" align="center"> 
					<%=df2.format(quantity_Fruit)%>份
				</td>
				<td class="style"></td>
				<td class="style">
					<div class="class2" align="center">
						&nbsp;油脂<%=df2.format(img_Fat)%>湯匙及堅果種子類1份
					</div> 
				</td>
			</tr>
		</table>
		<br>
		<table width="90%" align="center" border="1">
			<tr>
				<td align="center"><span>六大類食物</span></td>
				<td align="center"><span>早餐</span></td>
				<td align="center"><span>午餐</span></td>
				<td align="center"><span>晚餐</span></td>
			</tr>
			<tr>
				<td align="center"><span>低脂奶類</span></td>
				<td align="center"><span><%=df2.format(breakfast_Milk)%></span></td>
				<td align="center"><span><%=df2.format(lunch_Milk)%></span></td>
				<td align="center"><span><%=df2.format(dinner_Milk)%></span></td>
			</tr>
			<tr>
				<td align="center"><span>蔬菜類</span></td>
				<td align="center"><span><%=df2.format(breakfast_Veg)%></span></td>
				<td align="center"><span><%=df2.format(lunch_Veg)%></span></td>
				<td align="center"><span><%=df2.format(dinner_Veg)%></span></td>
			</tr>
			<tr>
				<td align="center"><span>水果類</span></td>
				<td align="center"><span><%=df2.format(breakfast_Fruit)%></span></td>
				<td align="center"><span><%=df2.format(lunch_Fruit)%></span></td>
				<td align="center"><span><%=df2.format(dinner_Fruit)%></span></td>
			</tr>
			<tr>
				<td align="center"><span>全穀根莖類</span></td>
				<td align="center"><span><%=df2.format(breakfast_Grain)%></span></td>
				<td align="center"><span><%=df2.format(lunch_Grain)%></span></td>
				<td align="center"><span><%=df2.format(dinner_Grain)%></span></td>
			</tr>
			<tr>
				<td align="center"><span>豆魚肉蛋類</span></td>
				<td align="center"><span><%=df2.format(breakfast_Meat)%></span></td>
				<td align="center"><span><%=df2.format(lunch_Meat)%></span></td>
				<td align="center"><span><%=df2.format(dinner_Meat)%></span></td>
			</tr>
			<tr>
				<td align="center"><span>油脂及堅果種子類</span></td>
				<td align="center"><span><%=df2.format(breakfast_Fat)%></span></td>
				<td align="center"><span><%=df2.format(lunch_Fat)%></span></td>
				<td align="center"><span><%=df2.format(dinner_Fat)%></span></td>
			</tr>
		</table>
		<br>
		<span align="center" class="HEAD_STYLE">可用食物</span>
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>全穀根莖類</span><br></div>
			<%=_classificationfood.webpublish(whole_grain_Suit) %>		
			</td></tr>					
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>豆魚肉蛋類</span><br></div>
			<%=_classificationfood.webpublish(meat_Suit) %>		
			</td></tr>
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>油脂及堅果種子類</span><br></div>
			<%=_classificationfood.webpublish(fat_Suit) %>		
			</td></tr>
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>低脂奶類</span><br></div>
			<%=_classificationfood.webpublish(milk_Suit) %>		
			</td></tr>
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>水果類</span><br></div>
			<%=_classificationfood.webpublish(fruit_Suit) %>			
			</td></tr>
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>蔬菜類</span><br></div>
			<%=_classificationfood.webpublish(vegetables_Suit) %>			
			</td></tr>
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>其他類</span><br></div>
			<%=_classificationfood.webpublish(other_Suit) %>			
			</td></tr>
		</table>
	</br>
	<span align="center" class="HEAD_STYLE">禁忌食物</span>
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>全穀根莖類</span><br></div>
			<%=_classificationfood.webpublish(whole_grain_NotSuit) %>		
			</td></tr>					
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>豆魚肉蛋類</span><br></div>
			<%=_classificationfood.webpublish(meat_NotSuit) %>		
			</td></tr>
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>油脂及堅果種子類</span><br></div>
			<%=_classificationfood.webpublish(fat_NotSuit) %>		
			</td></tr>
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>低脂奶類</span><br></div>
			<%=_classificationfood.webpublish(milk_NotSuit) %>			
			</td></tr>
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>水果類</span><br></div>
			<%=_classificationfood.webpublish(fruit_NotSuit) %>			
			</td></tr>
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>蔬菜類</span><br></div>
			<%=_classificationfood.webpublish(vegetables_NotSuit) %>			
			</td></tr>
		</table>
		
		<table align="center" border="1">
			<col style="width:40%">			
			<tr><td align="left" valign="top">
			<div align=center><span>其他類</span><br></div>
			<%=_classificationfood.webpublish(other_NotSuit) %>			
			</td></tr>
		</table>
	</div>
</body>
</html>